package com.yztc.yidoutang.activity.quanwu_activity;

import com.yztc.yidoutang.bean.QuanWuBean;
import com.yztc.yidoutang.bean.QuanWuListBean;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by My on 2016/10/18.
 */

public class QuanWuPresenter implements QuanWuContract.Presenter {
    private List<QuanWuListBean> allList=new ArrayList<>();
    private QuanWuContract.Model model;
    private QuanWuContract.View view;
    private Map<String,String> map;

    public QuanWuPresenter(QuanWuContract.View view) {
        this.view = view;
        this.model=new QuanWuModel();
    }

    @Override
    public void getDataForNet(String page) {
        map=new HashMap<>();
        //http://m.yidoutang.com/apiv3/case/list?page=1&order=0&last_group_id=0
        map.put("page",page);
        map.put("order","0");
        map.put("last_group_id","0");
        if (Integer.parseInt(page)==1){
            allList.clear();
        }

        model.getQuanWuData(map, new QuanWuContract.OnLoadQuanWuListener() {
            @Override
            public void onSuccess(QuanWuBean quanWuBean) {

                List<QuanWuListBean> list=quanWuBean.getData().getCases();
                allList.addAll(list);
                view.onQuanWuSuccess(allList);

            }

            @Override
            public void onFail(Exception e) {

            }
        });
    }
}
